# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=unrar
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=6.2.10
pkgrel=1
pkgdesc='The RAR uncompression program (mingw-w64)'
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://www.rarlab.com/rar_add.htm'
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=("https://www.rarlab.com/rar/unrarsrc-${pkgver}.tar.gz"
        0001-fix-makefile.patch
        0002-fix-redefinition.patch
        0003-workaround-comsupp-library.patch)
sha256sums=('55fe6ebd5e48d6655bfda3fd19b55438ca05e13c7e69772420caad9fdb68ef42'
            'fe1be3be4aecba4d57baa60788de3a9acb9f38b5ee871ca05a86c20bc92eff68'
            '9882f163dfbf04ad6946e99690799bb5de50894688fbe3f3df00e5c54f74e0b2'
            '707726b9280d7c929012e0c1d0af26b9fc86b8f3cb13ecd6c867e735adf722ba')

prepare() {
  cd ${_realname}
  patch -p1 -i "${srcdir}/0001-fix-makefile.patch"
  patch -p1 -i "${srcdir}/0002-fix-redefinition.patch"
  patch -p1 -i "${srcdir}/0003-workaround-comsupp-library.patch"
}

build() {
  cd ${_realname}
  make
}

package() {
  cd ${_realname}
  install -Dm755 unrar.exe "${pkgdir}${MINGW_PREFIX}/bin/unrar.exe"
  install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
